<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <h:head>
        <title>Course Schedule</title>
    </h:head>
    <h:body>
        <h:form>			
	<p:growl id="popup-message" showDetail="true" sticky="false" />
	<!--
        <p:toolbar>  
            <p:toolbarGroup align="middle">  
            <p:commandButton type="button" value="New Course Wizard" />
            <p:separator />
            <p:selectOneButton value="Course Calendar">
                <p:ajax event="change" update="popup-message" />
                <f:selectItem itemLabel="Course Calendar" itemValue="1" />  
                <f:selectItem itemLabel="Course Table" itemValue="2" />  
            </p:selectOneButton>
            </p:toolbarGroup>
        </p:toolbar>
 -->
 <p:panel header="Course Calendar" toggleable="true">
            <p:schedule id="schedule" value="#{scheduleController.eventModel}" widgetVar="myschedule" resizable="true" draggable="true" view="month" showHeader="false">    
                        <p:ajax event="dateSelect" listener="#{scheduleController.onDateSelect}" update="eventDetails" 
                                oncomplete="PF('eventDialog').show();" />  
                        <p:ajax event="eventSelect" listener="#{scheduleController.onEventSelect}" update="eventDetails" 
                                oncomplete="PF('eventDialog').show();" />
                        <p:ajax event="eventMove" listener="#{scheduleController.onEventMove}" update="popup-message"/>  
                        <p:ajax event="eventResize" listener="#{scheduleController.onEventResize}"  update="popup-message"/>  
                    </p:schedule>
        
        <p:dialog widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">  
                    <h:panelGrid id="eventDetails" columns="4">
                      
                    <h:outputLabel for="title" value="Class name:" />  
                    <p:inplace editor="true">
                        <p:inputText id="title" value="#{scheduleController.event.title}" required="true"/>
                    </p:inplace>
                    
                    <h:outputLabel for="location" value="Region:" />
                    <p:selectOneMenu id="location" >
                        <f:selectItems value="#{regionList.locations}" var="loc"
                                                  itemValue="#{selectedlocation}"/>
                    </p:selectOneMenu>
                    
                   <h:outputLabel for="setTime" value="Start Time:" />
                   <p:calendar id="setTime" value="#{scheduleController.event.startDate}"
                               mindate="#{scheduleController.event.theBeginningOfStartDay}"
                               maxdate="#{scheduleController.event.theEndingOfStartDay}" pattern="yyyy/MM/dd HH:mm" /> 
                   
                  <h:outputLabel for="to" value="To:" />
                    <p:calendar id="to" value="#{scheduleController.event.endDate}" mindate="#{scheduleController.event.startDate}" 
                                pattern="yyyy/MM/dd HH:mm" effect="drop"/>
                    
                    <p:inplace editor="true">
                        <f:facet name="output">
                            Yes or No
                        </f:facet>
                        <f:facet name="input">
                            <h:selectBooleanCheckbox />
                        </f:facet>
                    </p:inplace>
                    <f:facet name="footer">
                        <p:commandButton id="addButton" value="Save" actionListener="#{scheduleController.addEvent}" 
                             oncomplete="PF('myschedule').update();PF('eventDialog').hide();"/>
                    </f:facet>
              
        </h:panelGrid>  
    </p:dialog>
            
	</p:panel>
</h:form>
    </h:body> 
</html>

